<script lang="ts" setup>
import { ref } from 'vue'
const currentPage = ref<number>(1)
const pageSize = ref<number>(10)
const background = ref<boolean>(true)

const handleSizeChange = (val: number) => {
  pageSize.value = val
  currentPage.value = 1
}

const handleCurrentChange = (val: number) => {
  currentPage.value = val
}

const tableData = [
  {
    name: '张三',
    position: '家族管理员',
  },
  {
    name: '张三',
    position: '家族管理员',
  },
  {
    name: '张三',
    position: '家族管理员',
  },
  {
    name: '张三',
    position: '家族管理员',
  },
  {
    name: '张三',
    position: '家族管理员',
  },
  {
    name: '张三',
    position: '家族管理员',
  },
  {
    name: '张三',
    position: '家族管理员',
  },
  {
    name: '张三',
    position: '家族管理员',
  },
  {
    name: '张三',
    position: '家族管理员',
  },
  {
    name: '张三',
    position: '家族管理员',
  },
]

const total = ref(tableData.length)
</script>

<template>
 <div class="clan-member-table">
  <el-card class="member-list-card shadow-elegant">
    <div class="table-header">
      <h2 class="section-title font-serif">理事会成员</h2>
    </div>
        
    <!-- 表格区域 -->
    <div class="table-wrapper">
       <div class="table-container">
      <el-table 
        :data="tableData" 
        stripe 
        class="custom-table"
        :header-cell-style="{ 
          backgroundColor: '#8B4513', 
          color: '#8c786d',
          fontWeight: 'bold',
          textAlign: 'center',
          fontSize: '16px'
        }"
        :cell-style="{ textAlign: 'center', padding: '16px 12px' }"
        :row-style="{ height: '60px' }"
      >
        <el-table-column 
          type="index" 
          label="序号" 
          width="120" 
          align="center"
          
        />
        <el-table-column 
          prop="name" 
          label="姓名" 
          width="180" 
          align="center"
          class-name="name-column"
        />
        <el-table-column 
          prop="position" 
          label="职位" 
          align="center" 
          width="200"
          class-name="position-column"
        />
        <el-table-column label="操作" align="center" min-width="400">
          <template #default>
            <div class="action-buttons">
              <el-button 
                type="primary" 
                size="small" 
                round
              >
                家族详情
              </el-button>
              <el-button 
                type="info" 
                size="small" 
                round
              >
                联系此人
              </el-button>
              <el-button 
                type="warning" 
                size="small" 
                round
              >
                更换角色
              </el-button>
              <el-button 
                type="danger" 
                size="small" 
                round
              >
                删除成员
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>

      <!-- 优化分页组件样式 -->
      <div class="pagination-wrapper">
        <el-pagination
          v-model:current-page="currentPage"
          v-model:page-size="pageSize"
          :background="background"
          layout="total, prev, pager, next, jumper"
          :total="total"
          class="custom-pagination"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </div>
    </div>
  </el-card>
</div>
</template>

<style lang="scss" scoped>
.clan-member-table {
  width: 100%;
  min-height: 100vh;
  background: linear-gradient(135deg, #f8f6f0 0%, #f5f2e8 50%, #f0ede5 100%);
}

.member-list-card {
  border-radius: 16px;
  border: 2px solid #d4aa37;
  background: linear-gradient(145deg, #fefcf8 0%, #faf8f2 100%);
  box-shadow: 
    0 8px 32px rgba(139, 69, 19, 0.1),
    0 4px 16px rgba(212, 175, 55, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  padding: 2.5rem;
  position: relative;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #d4af37 0%, #b8860b 50%, #d4af37 100%);
    border-radius: 16px 16px 0 0;
  }
  
  .section-title {
    font-size: 2rem;
    color: #8b4513;
    font-weight: 700;
    position: relative;
    padding-left: 2rem;
    margin-bottom: 2rem;
    font-family: 'SimSun', serif;
    letter-spacing: 2px;
    
    &::before {
      content: '●';
      position: absolute;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      color: #dc143c;
      font-size: 1.2rem;
      text-shadow: 0 2px 4px rgba(220, 20, 60, 0.3);
    }
    
    &::after {
      content: '';
      position: absolute;
      bottom: -8px;
      left: 0;
      width: 60px;
      height: 3px;
      background: linear-gradient(90deg, #d4af37, #b8860b);
      border-radius: 2px;
    }
  }
}

.table-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
}

.table-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

:deep(.custom-table) {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(139, 69, 19, 0.1);
  border: 1px solid #e8dcc0;
  
  .el-table__header {
    background: linear-gradient(135deg, #8b4513 0%, #a0522d 100%);
    
    th {
      background: transparent !important;
      border-bottom: 2px solid #654321;
      font-family: 'SimSun', serif;
      letter-spacing: 1px;
    }
  }
  
  .el-table__body {
    tr {
      transition: all 0.3s ease;
      
      &:hover {
        background-color: #faf8f2 !important;
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(139, 69, 19, 0.1);
      }
      
      &:nth-child(even) {
        background-color: #fefcf8;
      }
    }
    
    td {
      border-bottom: 1px solid #f0ede5;
      font-family: 'SimSun', serif;
      color: #5d4037;
      font-weight: 500;
    }
  }
  
  .name-column {
    font-weight: 600;
    color: #8b4513;
  }
  
  .position-column {
    color: #eaea75;
    font-style: italic;
  }
}

.action-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  
  .el-button {
    font-size: 13px;
    padding: 8px 16px;
    font-family: 'SimSun', serif;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    border-width: 1px;
  } 
}

.pagination-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e8dcc0;
}

:deep(.custom-pagination) {
  .el-pagination__total {
    color: #8b4513;
    font-weight: 600;
    font-family: 'SimSun', serif;
  }
  
  .el-pager li {
    background-color: #fefcf8;
    border: 1px solid #e8dcc0;
    color: #8b4513;
    font-weight: 500;
    margin: 0 2px;
    border-radius: 6px;
    transition: all 0.3s ease;
    
    &:hover {
      background-color: #f5f2e8;
      border-color: #d4af37;
      transform: translateY(-1px);
    }
    
    &.is-active {
      background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
      border-color: #d4af37;
      color: white;
      font-weight: 700;
    }
  }
  
  .btn-prev, .btn-next {
    background-color: #fefcf8;
    border: 1px solid #e8dcc0;
    color: #8b4513;
    border-radius: 6px;
    transition: all 0.3s ease;
    
    &:hover {
      background-color: #f5f2e8;
      border-color: #d4af37;
      transform: translateY(-1px);
    }
    
    &:disabled {
      background-color: #f9f7f4;
      color: #bbb;
      border-color: #f0ede5;
    }
  }
  
  .el-pagination__jump {
    color: #8b4513;
    font-family: 'SimSun', serif;
    
    .el-input__inner {
      border-color: #e8dcc0;
      border-radius: 6px;
      
      &:focus {
        border-color: #d4af37;
      }
    }
  }
}
</style>
